package com.guanyong.dao;

import com.guanyong.model.VideoCollectLogModel;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * Created by mxk on 2017/5/26.
 * 视频收藏日志
 */
public interface IVideoCollectLogDaoMapper {


    @Insert("INSERT INTO t_ad_videocollectlog" +
            "(f_classtype,f_userid,f_objectid,f_ip,f_apptype) VALUES"+
            "(#{fClasstype},#{fUserid},#{fObjectid},#{fIp},#{fApptype})")
    int insert(VideoCollectLogModel record);

    @Select("select * from t_ad_videocollectlog WHERE f_classtype=#{classtype} and " +
            " f_objectid=#{objectid} and f_userid=#{userid} limit 1")
    @ResultMap("CollectLogResultMap")
    VideoCollectLogModel GetCollectModel(@Param("classtype") Integer classtype,
                                         @Param("objectid") String objectid,
                                         @Param("userid") String userid);

    @Select("select * from t_ad_videocollectlog WHERE f_id=#{id}")
    @ResultMap("CollectLogResultMap")
    VideoCollectLogModel GetCollectModelById(@Param("id") Integer id);


    @Select("select * from t_ad_videocollectlog WHERE f_userid=#{userid} and f_objectid=#{objectid} LIMIT 1")
    @ResultMap("CollectLogResultMap")
    VideoCollectLogModel GetCollectModelByObjectId(@Param("userid") String userid,
                                                   @Param("objectid") String objectid);


    //取消收藏
    @Delete("DELETE FROM t_ad_videocollectlog WHERE f_id=#{id}")
    int delete(Integer id);


//    @Delete("DELETE FROM t_ad_videocollectlog WHERE f_id=#{id}")
    @Delete("DELETE from t_ad_videocollectlog WHERE  f_id in (${idList})")
    int deleteIdlist(@Param("idList")String fidList);

    @Select("select * from t_ad_videocollectlog WHERE f_userid=#{userid} " +
            "LIMIT  #{offset},#{limit} ")
    @ResultMap("CollectLogResultMap")
    List<VideoCollectLogModel> SelectCollectList(@Param("userid")String  userid,
                                              @Param("offset")Integer offset,
                                              @Param("limit") Integer limit);
    @Select("select Count(*) from t_ad_videocollectlog WHERE f_userid=#{userid} " +
            "")
    Integer SelectCollectListCount(@Param("userid")String  useridl);

    @Select("select * from t_ad_videocollectlog WHERE f_userid=#{userid} " +
            " and f_objectid=#{objectid} ")
    @ResultMap("CollectLogResultMap")
    VideoCollectLogModel GeyMyCollectByVideoid(@Param("userid")String  userid,
                                               @Param("objectid")String  objectid);
}
